package wowraidmanager.client.auction;

import wowraidmanager.client.auction.about.About;
import wowraidmanager.client.auction.data.DataList;

import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.MenuItem;
import com.google.gwt.user.client.ui.Widget;

public class Index extends Composite{

    private static IndexUiBinder uiBinder = GWT.create(IndexUiBinder.class);

    interface IndexUiBinder extends UiBinder<Widget, Index>{
    }

    @UiField
    FlowPanel mainPanel;

    @UiField
    MenuItem topMenu;

    @UiField
    MenuItem aboutMenu;

    public Index(){
        initWidget(uiBinder.createAndBindUi(this));
        setTop();
        setMenu();
    }

    private void setMenu(){
        topMenu.setCommand(new Command(){

            public void execute(){
                setRemove();
                setTop();
            }
        });

        aboutMenu.setCommand(new Command(){

            public void execute(){
                setRemove();
                setAbout();
            }
        });
    }

    protected void setAbout(){
        mainPanel.add(new About());
    }

    protected void setRemove(){
        mainPanel.remove(0);
    }

    private void setTop(){
        mainPanel.add(new DataList());
    }

}
